<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>倒计时1</title>
</head>

<body>
    <button>发送</button>
    <script>
        var btn = document.querySelector('button');

        function countDown(s) {
            btn.addEventListener('click', () => {
                var time = s;
                btn.disabled = 'disabled';
                btn.innerHTML = time + '秒后重新可发送';
                var timer = setInterval(() => {
                    console.log(time);
                    if (time == 1) {
                        btn.innerHTML = '发送';
                        clearInterval(timer);
                        btn.removeAttribute('disabled');
                    } else {
                        time--;
                        btn.innerHTML = time + '秒后重新可发送';
                    }
                }, 1000)
            });
        }
        countDown(10);

    </script>
</body>

</html>